<template>
	<view class="content">
		<view class="top">
			<zbar></zbar>
			<view class="block" style="margin-top: 88rpx;">
				<view class="day">
					<view class="">
						<span class="s1">{{new Date().getDate()}}</span>/{{new Date().getMonth() + 1}}
						<span class="s2">月</span>
					</view>
					<image src="/static/index/i4.png" mode=""></image>
				</view>

				<view class="imgbot">
					<image src="/static/index/i2.png" mode=""></image>
					<view class="imgtip" @click="gologin">
						<image src="/static/index/i3.png" mode=""></image>
						<view class="test">
							数据概览
						</view>
					</view>
					<view class="testabs">
						<view class="ites">
							<view class="test">
								<span>{{OrdersCount.countProduct}}</span>份
							</view>
							<view class="">
								上架
							</view>
						</view>
						<view class="ites">
							<view class="test">
								<span>{{OrdersCount.countPay}}</span>份
							</view>
							<view class="">
								已售
							</view>
						</view>
						<view class="ites">
							<view class="test">
								<span>{{OrdersCount.countTake}}</span>份
							</view>
							<view class="">
								已取
							</view>
						</view>
						<view class="ites">
							<view class="test">
								<span>{{OrdersCount.countOrder}}</span>单
							</view>
							<view class="">
								订单
							</view>
						</view>
					</view>
				</view>
				<view class="imgabs">
					<image src="/static/index/i1.png" mode=""></image>
					<view class="poa">
						<view class="tname">
							<view class="flex_b">
								<span>[</span>
								<view class="name">
										{{shopInfo.shopName}}
								</view>
								<span>]</span>
								的小店
							</view>
						</view>
						<view class="set" @click="gosetshop">
							前往设置
						</view>
					</view>
				</view>
			</view>
			<view class="block_1">
				<view class="items">
					<view class="tit">
						<image src="/static/index/i5.png" mode=""></image>
						订单<span>(￥)</span>
					</view>
					<view class="price">
						{{OrdersAmount.amountOrder| numberToCurrencyNo}}
					</view>
				</view>
				<view class="items">
					<view class="tit">
						<image src="/static/index/i6.png" mode=""></image>
						有效<span>(￥)</span>
					</view>
					<view class="price">
						{{OrdersAmount.amountPay| numberToCurrencyNo}}
					</view>
				</view>
				<view class="items">
					<view class="tit">
						<image src="/static/index/i7.png" mode=""></image>
						退款<span>(￥)</span>
					</view>
					<view class="price">
						{{OrdersAmount.amountRefund| numberToCurrencyNo}}
					</view>
				</view>
			</view>

		</view>
		<view class="block_2" @click="ce">
			<view class="tit">
				待取商品（{{ulist.length}}）
			</view>
			<view class="uflex" >
				<view class="item" v-for="(item,index) in ulist" :key="index">
					<view class="item_card">
						<image src="/static/index/juan.png" mode=""></image>
						<view class="abs">
							<view class="t1">{{item.takeCode}}</view>
							<view class="t2">Id：{{item.id}}</view>
						</view>
					</view>
					<view class="name">
						{{item.productName}}
					</view>
					<view class="time">
						<image src="/static/z.png" mode=""></image>
						{{item.takeTimeBegin}}-{{item.takeTimeEnd}}
					</view>
				</view>
				<view class="kong" v-if="ulist.length == 0">
					<image src="/static/kong.png" mode=""></image>
					<view class="ts">
						暂无待取商品
					</view>
				</view>
			</view>
		</view>
	
		<uv-tabbar :value="0" class="tab"></uv-tabbar>
	</view>
</template>

<script>
	import {
		getShopinfo,getAmountList,getOrdersCount,getOrdersAmount
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				shopInfo:{},
				OrdersCount:{},
				OrdersAmount:{},
				
				ulist:[]
			}
		},
		onShow() {
			if(uni.getStorageSync('sjtoken')){
				getShopinfo({}).then(res=>{
					uni.setStorageSync('userinfo',res.data)
					this.shopInfo = res.data
				})
				getOrdersCount({}).then(res=>{
					this.OrdersCount = res.data
				})
				getOrdersAmount({}).then(res=>{
					this.OrdersAmount = res.data
				})
				this.getList()
			}else{
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
		},
		onLoad() {
			if(uni.getStorageSync('sjtoken')){
				this.getList()
			}else{
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
		},
		onReachBottom() {
			console.log('11');
		},
		methods: {
			getList(){
				getAmountList({}).then(res=>{
					this.ulist= res.rows
				})
			},
			ce() {
				uni.login({
					provider: 'weixin', //使用微信登录
					success: function(loginRes) {
						console.log(loginRes);
					}
				});
			},
			gosetshop(){
				uni.navigateTo({
					url: '/pages/user/setshop'
				})
			},
			gologin() {
				uni.navigateTo({
					url: '/pages/index/settled'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #FBFBFB;
		height: 100vh;
	}

	.top {
		width: 750rpx;
		height: 835rpx;
		background: linear-gradient(180deg, #B9EFCF 0%, #FBFBFB 100%);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		padding: 0rpx 20rpx;
		box-sizing: border-box;

		.block {
			position: relative;

			.day {
				margin-top: 10rpx;
				margin-left: 22rpx;
				display: flex;
				align-items: center;
				font-family: 'DINB';
				font-weight: bold;
				color: #000000;

				.s1 {
					font-size: 80rpx;
				}

				.s2 {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #000000;
					margin-left: 10rpx;
				}

				image {
					width: 60rpx;
					height: 57rpx;
					margin-top: 20rpx;
					margin-left: 10rpx;
				}
			}

			.testabs {
				position: absolute;
				top: 148rpx;
				display: flex;
				justify-content: space-evenly;
				width: 100%;

				.test {
					font-size: 20rpx;

					span {
						font-family: 'DINB';
						font-weight: bold;
						font-size: 48rpx;
						color: #1E703F;
					}
				}

				.ites {
					text-align: center;
					width: 25%;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #979797;
					line-height: 40rpx;
					margin-bottom: 10rpx;
				}
			}

			.imgbot {
				margin-top: 42rpx;
				position: absolute;
				z-index: 9;

				image {
					width: 710rpx;
					height: 292rpx;
				}
			}

			.imgtip {
				position: absolute;
				top: 26rpx;
				left: 20rpx;
				display: flex;
				justify-content: center;

				.test {
					position: absolute;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 30rpx;
					color: #000000;
					top: 14rpx;
				}

				image {
					width: 224rpx;
					height: 78rpx;
				}
			}

			.imgabs {
				right: 20rpx;
				top: 0%;
				position: absolute;

				image {
					width: 280rpx;
					height: 270rpx;
				}

				.poa {
					position: absolute;
					top: 0%;
					width: 280rpx;
					height: 270rpx;
					z-index: 9;
					.tname {
						display: flex;
						align-items: center;
						justify-content: center;
						font-family: PingFang SC, PingFang SC;
						font-size: 26rpx;
						color: #000;
						margin: 84rpx auto 0rpx;
						span {
							color: #1E703F;
						}
						.name {
							font-weight: bold;
							font-size: 26rpx;
							color: #1E703F;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							width: 150rpx;
							text-align: center;
						}
					}

					.set {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 20rpx;
						color: #1E703F;
						margin-top: 32rpx;
						text-align: center;
					}
				}
			}
		}

		.block_1 {
			width: 710rpx;
			height: 200rpx;
			background: linear-gradient(180deg, #D7FCE6 0%, #EEFDF4 100%);
			box-shadow: inset 6rpx 6rpx 20rpx 0rpx rgba(255, 255, 255, 0.6);
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			border: 2rpx solid #FFFFFF;
			margin-top: 360rpx;
			padding: 44rpx 20rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;

			.items {
				image {
					width: 44rpx;
					height: 44rpx;
					margin-right: 10rpx;
				}

				.tit {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #000000;
					display: flex;
					align-items: center;

					span {
						font-size: 24rpx;
						color: #979797;
					}
				}

				.price {
					align-items: center;
					font-family: 'DINB';
					font-weight: bold;
					color: #000000;
					font-size: 40rpx;
					margin-top: 30rpx;
				}
			}
		}
	}

	.block_2 {
		padding: 20rpx;

		.tit {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #000000;
		}

		.uflex {
			background: #FFFFFF;
			display: flex;
			flex-wrap: wrap;
			padding: 38rpx 64rpx;
			box-sizing: border-box;
			justify-content: space-between;
			margin-top: 20rpx;
			min-height: 500rpx;
			.kong{
				text-align: center;
				width: 278rpx;
				margin: 60rpx auto;
				.ts{
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #D1D1D6;
					margin-top: 30rpx;
				}
				image{
					width: 278rpx;
					height: 265rpx;
				}
			}
			.item{
				margin-bottom: 30rpx;
			}
			.item_card {
				width: 262rpx;
				height: 196rpx;
				background: #F7F8FA;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
				image{
					width: 222rpx;
					height: 131rpx;
				}
				.abs{
					position: absolute;
					width: 222rpx;
					height: 131rpx;
					text-align: center;
					.t1{
						font-family:'DINB';
						font-weight: bold;
						font-size: 64rpx;
						color: #000000;
						line-height: 94rpx;
					}
					.t2{
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #1E703F;
						line-height: 38rpx;
					}
					
				}
			}
		    .name{
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #000000;
				margin-top: 23rpx;
			}
			.time{
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #979797;
				display: flex;
				align-items: center;
				margin-top: 8rpx;
				image{
					width: 32rpx;
					height: 32rpx;
				}
			}
		}

	}
</style>